package com.zy.cat.entity.mall.repository;

import java.util.List;

import javax.transaction.Transactional;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.zy.cat.entity.mall.TKTLJGoodsOrders;

public interface TKTLJGoodsOrdersRepository
		extends JpaSpecificationExecutor<TKTLJGoodsOrders>, JpaRepository<TKTLJGoodsOrders, String> {
	
	TKTLJGoodsOrders findByPidAndSid(String pid,String sid);
	
	List<TKTLJGoodsOrders> findByPidAndTtype(String pid,int ttype);
	
	List<TKTLJGoodsOrders> findByPid(String pid );
	
	@Transactional
	@Query(value = "SELECT IFNULL(SUM(tlj),0) FROM zy_cat_tlj_order_ori WHERE pid=:pid",nativeQuery = true)
	long getTLK(@Param("pid")String pid);
}
